// 搜索功能
document.querySelector('.search-input').addEventListener('input', function(e) {
	const searchText = e.target.value.toLowerCase();
	const rows = document.querySelectorAll('tbody tr');

	rows.forEach(row => {
		const name = row.children[1].textContent.toLowerCase();
		row.style.display = name.includes(searchText) ? '' : 'none';
	});
});

// 状态筛选
document.querySelector('.filter-select').addEventListener('change', function(e) {
	const status = e.target.value;
	const rows = document.querySelectorAll('tbody tr');

	rows.forEach(row => {
		const rowStatus = row.querySelector('.status').textContent;
		if (!status || rowStatus === status) {
			row.style.display = '';
		} else {
			row.style.display = 'none';
		}
	});
});

// 编辑和停用/启用按钮
document.querySelectorAll('.action-btn').forEach(btn => {
	btn.addEventListener('click', function() {
		const action = this.textContent;
		const row = this.closest('tr');
		const name = row.children[1].textContent;

		if (action === '编辑') {
			alert(`编辑管理员: ${name}`);
		} else {
			const newStatus = action === '停用' ? '已停用' : '正常';
			const statusSpan = row.querySelector('.status');
			statusSpan.textContent = newStatus;
			statusSpan.className = `status status-${newStatus === '正常' ? 'active' : 'inactive'}`;
			this.textContent = newStatus === '正常' ? '停用' : '启用';
		}
	});
});
// 分页按钮
document.querySelectorAll('.page-btn').forEach(btn => {
	btn.addEventListener('click', function() {
		if (this.textContent === '上一页' || this.textContent === '下一页') {
			return;
		}
		document.querySelectorAll('.page-btn').forEach(b => b.classList.remove('active'));
		this.classList.add('active');
	});
});